package com.young.ysepay.controllers;

import com.young.ysepay.service.YsReportService;
import com.young.ysepay.utils.JSONUtils;
import com.young.ysepay.utils.ReturnUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @anthor wenguoqiang
 * @date: 2019/06/06 9:53
 * @company 够样
 * @des
 **/
@RestController
@RequestMapping("/ysReport")
public class YsReportController {

    private static Logger log = LoggerFactory.getLogger(YsController.class);

    @Autowired
    private YsReportService ysReportService;

    @PostMapping("/registryStore")
    public Object registryStore(@RequestParam Map<String, Object> mapParams) {
        log.info("----------------------银盛报备商户信息开始-------------------");

        Map<String, Object> returnMap = null;
        String responseStr = "";
        try {
            returnMap = ysReportService.requertRegistryStore(mapParams);
        } catch (Exception e) {
            returnMap = ReturnUtils.getExceptionResult(log,e);
        } finally {
            responseStr = JSONUtils.objectToJson(returnMap);
        }
        return ReturnUtils.appendResultStr(log,responseStr,"registryStore");
    }


    @RequestMapping(value = { "/notifyRegistry" }, produces = { "text/html;charset=UTF-8" }, method = {
            RequestMethod.POST })
    public void notifyRegistry(HttpServletRequest request){
        Map<String, String[]> requestParams = request.getParameterMap();
        ysReportService.notifyRegistry(requestParams);
    }


}
